const query = require('./index')

class CommentModel {
  constructor () {}

  static get_user_select(){
    const _sql = `SELECT * FROM user order by id DESC`;
    return query(_sql);
  }
  static user_select_name(val){
    const _sql = "select * from user where stu_name like concat('%','"+val+"','%')"
    return query(_sql,val)
  }
  static get_classRoom_select(){
    const _sql = 'SELECT * FROM classRoom WHERE class_type = "Y"'
    return query(_sql)
  }
  static get_classRoom_select_all(){
    const _sql = 'select * from  classRoom'
    return query(_sql)
  }
//   apply_教室申请
  static get_classRoom_select_apply(){
    const _sql = 'select id,room_bh,room_name,user_name,room_time,class_start from  apply WHERE classroom = "1"'
    return query(_sql)
  }

  static classroom_delete_by_id(values) {
    const _sql = 'DELETE FROM classRoom WHERE id = ' + values
    return query(_sql, values)
  }
    // 获取用户信息数据总条数
    static select_user_number(){
      const _sql = ` select t1.num1,t2.num2,t3.num3 from 
                    (select count(*) num1 from user) t1,
                    (select count(*) num2 from apply) t2,
                    (select count(*) num3 from notice) t3`
      return query(_sql)
    }
    // 获取待审批活动
    static get_apply_select_N(){
      const _sql = 'SELECT * FROM apply WHERE apply_start = "N" order by id DESC limit 9'
      return query(_sql)
    }

    // 更新教室信息
    static upload_classroom(values){
      const _sql = "UPDATE classroom SET class_name='" + values.class_name + "', class_type='" + values.class_type + "', class_other='" + values.class_other + "' WHERE  id="+ values.id
      return query(_sql)
    }
    static selsct_classroom_Y(){
      const _sql = 'select id,room_bh,room_name,user_name,room_time,class_start from  apply WHERE class_start = "Y"'
      return query(_sql)
    }
    static selsct_classroom_N(){
      const _sql = 'select id,room_bh,room_name,user_name,room_time,class_start from  apply WHERE class_start = "N"'
      return query(_sql)
    }
    static SET_classroom_y(values){
      const _sql = "UPDATE apply SET class_start='" + values.class_start + "' WHERE  id="+ values.id
      return query(_sql)
    }

    static selsct_apply_Y(){
      const _sql = 'select * from  apply WHERE apply_start = "Y" order by id DESC'
      return query(_sql)
    }
    static selsct_apply_N(){
      const _sql = 'select * from  apply WHERE apply_start = "N" order by id DESC'
      return query(_sql)
    }

    static SET_apply_NT(values){
      const _sql = "UPDATE apply SET class_start='Y' , apply_start='NT' WHERE  id="+ values.id
      return query(_sql)
    }
    static SET_apply_Y(values){
      const _sql = "UPDATE apply SET apply_start='Y' WHERE  id="+ values.id
      return query(_sql)
    }
    static get_apply_NT(){
      const _sql = "select * from  apply WHERE apply_start='NT' order by id DESC"
      return query(_sql)
    }


}

module.exports = CommentModel